class Dog:
    def __init__(self, new_name):
        self.name = new_name
        self.__age = 0  # 定义了一个私有的属性，属性的名字是__age

    def set_age(self, new_age):
        if new_age > 0 and new_age <= 100:
            self.__age = new_age
        else:
            self.__age = 0

    def get_age(self):
        return self.__age


dog = Dog("小白")
dog.age = -10
dog.name = "小白"

print(dog.age)  # 输出 -10

dog.set_age(-10)
age = dog.get_age()
print(age)  # 输出 0

dog.__age = -20  # 还可以设值啊
print(dog.__age)  # 输出 -20  TODO 竟然还可以输出  难道又是一个新的属性
print("测试 dog.__age=%d, dog.get_age()=%d" % (dog.__age, dog.get_age()))
print(dog.get_age())  # 输出 0
